﻿




using System.Collections.Generic;
using Hotpot.Models;
using Hotpot.Modules.Comments.Infrastructure;
using Hotpot.Modules.Comments.Services;

namespace Hotpot.Modules.Comments.Extensions
{
    public static class FillCommentsExtensions
    {
        public static IPageOfItems<T> FillComments<T>(this IPageOfItems<T> items, ICommentService commentService) where T : ICommentedEntity
        {
            foreach (T item in items)
                item.FillComments(commentService);

            return items;
        }

        public static IEnumerable<T> FillComments<T>(this IEnumerable<T> items, ICommentService commentService) where T : ICommentedEntity
        {
            foreach (T item in items)
                item.FillComments(commentService);

            return items;
        }

        public static T FillComments<T>(this T item, ICommentService commentService) where T : ICommentedEntity
        {
            commentService.FillComments(item);

            return item;
        }
    }
}
